package com.zl.customribbon.config;

import com.netflix.loadbalancer.*;
import org.springframework.cloud.netflix.ribbon.RibbonClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author zhouliang
 * @date 2019/12/12 17:07
 * ribbon的全局配置：代码配置方式
 */
@RibbonClients(defaultConfiguration = RibbonClientDefaultConfigurationTestsConfig.DefaultRibbonConfig.class)
public class RibbonClientDefaultConfigurationTestsConfig {

    @Configuration
    class DefaultRibbonConfig {

        @Bean
        public IRule ribbonRule() {
            return new ZoneAvoidanceRule();
        }

        @Bean
        public IPing ribbonPing() {
            return new PingUrl();
        }
    }
}